package com.xuebusi.toutiao.admin.api.user.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.xuebusi.toutiao.admin.api.common.exception.CustomException;
import com.xuebusi.toutiao.admin.api.common.result.ApiResult;
import com.xuebusi.toutiao.admin.api.user.entity.SourceEntity;
import com.xuebusi.toutiao.admin.api.user.entity.UserEntity;
import com.xuebusi.toutiao.admin.api.user.form.LoginForm;
import com.xuebusi.toutiao.admin.api.user.form.RegisterForm;
import com.xuebusi.toutiao.admin.api.user.form.UserForm;
import com.xuebusi.toutiao.admin.api.user.vo.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户服务接口
 */
public interface UserService extends IService<UserEntity> {
    /**
     * 登录
     *
     * @param loginForm 登录表单
     * @return
     */
    ResponseEntity<ApiResult<UserTokenVO>> authorizations(LoginForm loginForm);

    /**
     * 注册
     *
     * @param registerForm 注册表单
     * @return
     */
    ResponseEntity<ApiResult<UserEntity>> register(RegisterForm registerForm);

    /**
     * 修改用户头像
     *
     * @param file    文件
     * @param userId  用户id
     * @param request request
     * @return
     */
    ResponseEntity<ApiResult<UserPhotoVO>> updatePhoto(MultipartFile file, Integer userId, HttpServletRequest request);

    /**
     * 查询用户资料
     *
     * @param userId   用户id
     * @param userForm 修改表单
     * @return
     * @throws CustomException
     */
    ResponseEntity<ApiResult<UserProfileVO>> updateUserProfile(Integer userId, UserForm userForm) throws CustomException;

    /**
     * 查询用户资料
     *
     * @param userId 用户id
     * @return
     */
    ResponseEntity<ApiResult<UserDetailVO>> getUserProfile(Integer userId);

    /**
     * 刷新token
     *
     * @param auth token字符串
     * @return
     */
    ResponseEntity<ApiResult<RefreshTokenVO>> refreshToken(String auth);

    /**
     * 收藏 or 取消收藏
     *
     * @param userId   用户id
     * @param sourceId 资源id
     * @param collect  是否收藏
     * @return
     */
    ResponseEntity<ApiResult<CollectRVO>> collect(Integer userId, Integer sourceId, Boolean collect);

    /**
     * 上传图片素材
     *
     * @param userId  用户id
     * @param file    图片文件
     * @param request request
     * @throws CustomException
     */
    ResponseEntity<ApiResult<SourceEntity>> uploadImage(
            Integer userId, MultipartFile file, HttpServletRequest request) throws CustomException;

    /**
     * 删除图片素材
     *
     * @param userId   用户id
     * @param sourceId 资源id
     * @return
     */
    ResponseEntity deleteImage(Integer userId, Integer sourceId);
}
